// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   getRetailBalanceAmount.java

package stock;

import include.nseer_db.nseer_db;
import java.sql.ResultSet;

public class getRetailBalanceAmount
{

	public getRetailBalanceAmount()
	{
	}

	public double balanceAmount(String unit_db_name, String product_ID, String register_ID)
	{
		nseer_db dba = new nseer_db(unit_db_name);
		nseer_db dbb = new nseer_db(unit_db_name);
		double balance_amount = 0.0D;
		try
		{
			String sql1 = (new StringBuilder("select stock_ID from stock_config_public_char where responsible_person_ID like '%")).append(register_ID).append("%'").toString();
			ResultSet rs1 = dba.executeQuery(sql1);
			String stock_ID = "";
			while (rs1.next()) 
			{
				stock_ID = rs1.getString("stock_ID");
				String sql2 = (new StringBuilder("select * from stock_balance_details where product_ID='")).append(product_ID).append("' and stock_ID='").append(stock_ID).append("'").toString();
				ResultSet rs2 = dbb.executeQuery(sql2);
				if (rs2.next())
					balance_amount += rs2.getDouble("amount");
			}
			dbb.close();
			dba.close();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return balance_amount;
	}
}
